<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(dirname(__FILE__) . '/MY_Model.php');

class Blocks_m extends MY_Model {
	function __construct($db=null) {
        parent::__construct($db);
    }

    function set_where($params){
		if(isset($params['title']) && $params['title']) {
			$this->db->like('title',$params['title']);
		}
		if(isset($params['is_active']) && $params['is_active'] != '') {
			$this->db->where('is_active',$params['is_active']);
		}
		$this->db->from('blocks');
    }

    function count_data_blocks($params){
		$this->set_where($params);
		return $this->db->count_all_results();
    }

    function get_data_block($params){
		$this->set_where($params);
		$this->db->limit($params['limit'],$params['start']);
		$this->db->order_by('id','DESC');
		$query = $this->db->get();
		return $query->result();
    }
}